﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MinCostClimbingStairs
{
    public class Solution
    {
        public int MinCostClimbingStairs(int[] cost)
        {
            int minCost0 = 0;
            int minCost1 = Math.Min(cost[0], cost[1]);
            int minCost = 0;
            for (int i = 2; i < cost.Length; i++)
            {
                minCost = Math.Min(minCost1 + cost[i], minCost0 + cost[i - 1]);
                minCost0 = minCost1;
                minCost1 = minCost;
            }
            return minCost;
        }
    }
}
